Trigger

Hello,

I try to use "if" with "matches" and I do not know what is the fehler in my code

 I get my infobox message " this object have inlink do not empty result " in both cases :

  • when I empty result
  • when I write in result ( result is enumeration attribute)

 

I want Trigger  just when i try to empty result attribute .

can anyone help please ?

....
bool match_empty = false 

string dxl_code="  
Object o = object current Trigger
match_empty = false 
LinkRef LR; for LR in o <-\"*\" do {
// attribute result is enumeration attribute
 if (matches(\"\",o.\"result\"\"\")){
 match_empty = true
 if (match_empty == true ){infoBox (\"this object have inlink do not empty result\")}  
    set trigPreConFail
 } 
    halt
}
set trigPreConPass
"
Trigger T = trigger (nameOfMyTrigger, project -> nameOfMyProject -> module -> nameOfMyModule -> attribute -> nameOfMyAttribute, pre, save, 2, dxl_code)

Regards,

Neven


Control17 - Wed Oct 11 06:30:23 EDT 2017

Re: Trigger
Mike.Scharnow - Fri Oct 13 04:19:32 EDT 2017

Hi Neven,

I did not look too much at the logic of your code, but to answer your question, if you want to compare the content of an attribute against a concrete value like "", you use the == comparison

if (o."Result" "" == ""){..

Matches is used for complex comparisons like "is value that is built from the following elements contained in string variable".

 

About your code: It might work, but it looks strange, there is no need for "match_empty". You have something like this.

    variable = 1
    if (variable == 1) {
        print "this line will always be executed, because variable cannot be anything else than 1 at this point. So, why should I compare variable against 1?"
    }

 

Re: Trigger
Control17 - Mon Oct 16 07:54:21 EDT 2017

Mike.Scharnow - Fri Oct 13 04:19:32 EDT 2017

Hi Neven,

I did not look too much at the logic of your code, but to answer your question, if you want to compare the content of an attribute against a concrete value like "", you use the == comparison

if (o."Result" "" == ""){..

Matches is used for complex comparisons like "is value that is built from the following elements contained in string variable".

 

About your code: It might work, but it looks strange, there is no need for "match_empty". You have something like this.

    variable = 1
    if (variable == 1) {
        print "this line will always be executed, because variable cannot be anything else than 1 at this point. So, why should I compare variable against 1?"
    }

 

Hello Mike,

Thanks for your Reply.

 

Regards,

Neven